package com.yl.ifanr.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
 * 数据库操作公共类
 * @author hhq163
 *
 */
public class BaseDao {
	private static final String TAG = "DbAdapter";
	private static final String DATABASE_NAME = "ifanr.db";
	private static final int DATABASE_VERSION = 1;
	
	public class DatabaseHelper extends SQLiteOpenHelper{
		public DatabaseHelper(Context context){
			super (context,DATABASE_NAME,null,DATABASE_VERSION);
		}
		/**
		 * 完成表创建工作
		 */
		public void onCreate(SQLiteDatabase db){
			//创建rss记录表
			String rss_sql = "CREATE TABLE t_rss_item "
					+"(id INTEGER primary key autoincrement, " 
					+ "title text not null, " 
					+ "link_url text ," 
					+ "desc text, " 
					+ "content text, " 
					+ "created long not null" 
					+ ");";
			db.execSQL(rss_sql);
			
		}
		/**
		 * 完成数据库升级
		 */
		public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){
			db.execSQL("DROP TABLE IF EXISTS t_rss_item;");
			onCreate(db);
		}
	}
}